<script setup xmlns="http://www.w3.org/1999/html">
import request from "@/util/request.js";
import { ref } from 'vue';
// import axios from "axios";
const response = ref("")
const dialogId = ref("")
const mode = ref(0)
const headers = {
  'Authorization' :'Bearer eyJhbGciOiJIUzI1NiJ9.eyJwaG9uZSI6IjE3NjY3Mzk5MTkzIiwiaWQiOjgsImlhdCI6MTc0NjQzNzA5OCwiZXhwIjoxNzQ2NTIzNDk4fQ.nD3M3SBAWCbjw3IoTWQYvMLeAvMeupYrkd8M5zHJDoA'
}
function selectAll(url) {
    request({
      method: 'get',
      url: url,
      headers: headers
    })
    .then(res => {
      response.value = res.data.data;
    })
    .catch(err => {
      response.value = err;
    })
}
function selectUserAll() {
  selectAll('/user/selectAll')
}
function selectDialogAll() {
  selectAll('/dialog/selectAll')
}
function selectMessageAll() {
  selectAll('/message/selectAll')
}
function selectLearnAll(){
  selectAll('/learn/selectAll')
}
function loadMessages() {
  request({
    method: 'get',
    url: '/aichat/load?dialogId=' + dialogId.value + '&mode=' + mode.value,
    headers : headers
  })
  .then(res => {
    console.log(res)
    response.value = res.data;
  }).catch(err => {
    response.value = err;
  })
}
</script>

<template>
  <br>
  <div>
    {{response}}
  </div>
  <br>
  <div>
    <button @click="selectUserAll">selectUserAll</button>
    <button @click="selectDialogAll">selectDialogAll</button>
<!--    <button @click="selectMessageAll">selectMessageAll</button>-->
    <button @click="selectLearnAll">selectLearnAll</button>
    <div>
      <br>
      <label>dialogId:</label>
      <input type="text" v-model="dialogId">
      <br>

      <label>mode:</label>
      <input type="text" v-model="mode">
      <br>

      <button @click="loadMessages">loadMessages</button>
    </div>

  </div>
</template>

<style scoped>

</style>
